{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<div class="action-block is-rounded" data-test-reindex-replication>
  <div class="action-block-info">
    <h3 class="title is-5 is-marginless">
      Reindex
    </h3>
    <p class="has-top-padding-s">
      Reindex the local data storage.
    </p>
  </div>
  <div class="action-block-action">
    <Hds::Button
      @text="Reindex"
      @color="secondary"
      {{on "click" (action (mut this.isModalActive) true)}}
      data-test-replication-action-trigger="reindex"
    />
  </div>
</div>
{{#if this.isModalActive}}
  <Hds::Modal id="replication-reindex-modal" @color="warning" @onClose={{fn (mut this.isModalActive) false}} as |M|>
    <M.Header @icon="alert-triangle">
      Begin reindex?
    </M.Header>
    <M.Body>
      <p class="has-bottom-margin-m">
        Reindexing can cause a very long delay depending on the number and size of objects in the data store.
        {{if this.model.replicationAttrs.isPrimary "You should always re-index your secondary first."}}
      </p>
      <p>
        Progress will be shown, and you will
        {{if this.model.replicationAttrs.isPrimary "not"}}
        be able to use Vault during this time.
      </p>
    </M.Body>
    <M.Footer as |F|>
      <Hds::ButtonSet>
        <Hds::Button @text="Reindex" {{on "click" (fn this.onSubmit "reindex")}} data-test-confirm-button />
        <Hds::Button @text="Cancel" @color="secondary" {{on "click" F.close}} data-test-reindex-cancel-button />
      </Hds::ButtonSet>
    </M.Footer>
  </Hds::Modal>
{{/if}}